|
|
 |
|
|
|
|
' Translate the point to the origin. m2Translate T, -x, -y
' Compute the inverse translation. m2Translate T_Inv, x, y
' Scale. m2Scale S, sx, sy
' Combine the transformations. m2MatMultiply M, T, S ' T * S m2MatMultiply Result, M, T_Inv ' T * S * T_Inv End Sub
' Create a matrix for reflecting across the line
' passing through (x, y) in direction <dx, dy>. Public Sub m2ReflectAcross(Result() As Single, _
ByVal x As Single, ByVal y As Single, _
ByVal dx As Single, ByVal dy As Single)
Dim T(1 To 3, 1 To 3) As Single
Dim R(1 To 3, 1 To 3) As Single
Dim S(1 To 3, 1 To 3) As Single
Dim R_Inv(1 To 3, 1 To 3) As Single
Dim T_Inv(1 To 3, 1 To 3) As Single
Dim M1(1 To 3, 1 To 3) As Single
Dim M2(1 To 3, 1 To 3) As Single
Dim M3(1 To 3, 1 To 3) As Single
' Translate the point to the origin. m2Translate T, -x, -y
' Compute the inverse translation. m2Translate T_Inv, x, y
' Rotate so the direction vector lies in the Y axis. m2RotateIntoX R, dx, dy
' Compute the inverse translation. m2RotateIntoX R_Inv, dx, -dy
' Reflect across the X axis. m2Scale S, 1, -1
' Combine the transformations. m2MatMultiply M1, T, R ' T * R m2MatMultiply M2, S, R_Inv ' S * R_Inv m2MatMultiply M3, M1, M2 ' T * R * S * R_Inv
' T * R * S * R_Inv * T_Inv m2MatMultiply Result, M3, T_Inv
End Sub |
|
|
|
|
|